package xiaohu.day0.HJ5;

import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            HashMap<String, Integer> map = new HashMap<>();
            map.put("A", 10);
            map.put("B", 11);
            map.put("C", 12);
            map.put("D", 13);
            map.put("E", 14);
            map.put("F", 15);
            int count=0;
            for (int i = 2; i < str.length(); i++) {
                if (map.containsKey(str.substring(i, i + 1))) {
                    count = count * 16 + map.get(str.substring(i, i + 1));
                } else {
                    count = count * 16 + Integer.parseInt(str.substring(i, i + 1));
                }
            }
            System.out.println(count);
        }
    }
}
